<?php  
defined('APPLICATION_URL')||define('APPLICATION_URL', '/ITjap(tung)/ITjap_finalversion');
session_start();
$userId=$_SESSION['userId'];
if(!isset($userId)) header('Location:'.APPLICATION_URL.'/index.php');
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>

<!-- head - Finished -->
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
	<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7" />
	<link rel="stylesheet" href="<?php echo APPLICATION_URL;?>/css/layout.css" type="text/css" media="screen" />
	<link rel="stylesheet" href="<?php echo APPLICATION_URL;?>/css/home.css" type="text/css" media="screen" />
	<link rel="stylesheet" href="<?php echo APPLICATION_URL;?>/css/sys.css" type="text/css" media="screen" />	
	<title>会議室予約システム</title>
</head>
<!-- /head - Finished -->

<body>
<!-- header area -->
	<div id="header_area">
	  <div id="header">
	    <div id="header_link_area">
	      <a name="pagetop"></a>
	      <div id="header_appeal">会議室予約システム</div>
	      <div id="header_link">
	        <ul>
	          <li class="header_b_1"><a href="<?php echo APPLICATION_URL;?>/index.php" class="header_b_1"><img src="<?php echo APPLICATION_URL;?>/images/header/header_b_1.gif" alt="ホーム" width="56" height="21" /></a></li>
	          <li class="header_b_2"><a href="<?php echo APPLICATION_URL;?>/IT_Nihongo/company.aspx" class="header_b_2"><img src="<?php echo APPLICATION_URL;?>/images/header/header_b_2.gif" alt="会社概要" width="71" height="21" /></a></li>
	          <li class="header_b_3"><a href="<?php echo APPLICATION_URL;?>/legalnotice.aspx" class="header_b_3"><img src="<?php echo APPLICATION_URL;?>/images/header/header_b_3.gif" alt="特定商取引に基づく表記" width="155" height="21" /></a></li>
	          <li class="header_b_4"><a href="<?php echo APPLICATION_URL;?>/contact.aspx" class="header_b_4"><img src="<?php echo APPLICATION_URL;?>/images/header/header_b_4.gif" alt="お問い合せ" width="82" height="21" /></a></li>
	        </ul>
	      </div>
	    </div>
	    <div id="header_title">
	       <img id="SiteHeader1_imgTitle" src="<?php echo APPLICATION_URL;?>/images/header/header_title_1.gif" alt="貸会議室予約" style="height:90px;width:960px;border-width:0px;" /> 
	    </div>
	  </div>
	</div>
<!-- header area-->
	
<!-- pan_area -->
	      <div id="pan_area">
	        <div id="pan">
	          <ul>
	            <li><a href="<?php echo APPLICATION_URL;?>/index.php">ホーム</a></li>
	          </ul>
	        </div>
	      </div>
<!-- pan_area -->
	  
<!-- main_area -->
	<div id="main_top_area">&nbsp;</div>
	    
	<!-- main_middle_area -->   
	<div id="main_middle_area">
	
	    <!-- main area-->
		<div id="main_area">
		
			<!-- main -->
			<div id="main">
				 <!-- navi -->
				      <div id="navi">
				        <ul>
				          <li class="tenanto_yoyaku"><a href="<?php echo APPLICATION_URL;?>/view/user/book_room.php" class="navi_b_1"><img src="<?php echo APPLICATION_URL;?>/images/navi/tenanto_yoyaku.gif" alt="会議室予約" width="145" height="39" /></a></li>
				          <li class="tenanto_sansho"><a href="<?php echo APPLICATION_URL;?>/view/user/view_room.php" class="navi_b_2"><img src="<?php echo APPLICATION_URL;?>/images/navi/tenanto_sansho.gif" alt="予約参照" width="145" height="39" /></a></li>
				          <li class="tenanto_setting"><a href="<?php echo APPLICATION_URL;?>/view/user/Change_Info.php" class="navi_b_3"><img src="<?php echo APPLICATION_URL;?>/images/navi/tenanto_setting.gif" alt="個人情報変更" width="145" height="39" /></a></li>
				          <li class="tenanto_resetpass"><a href="<?php echo APPLICATION_URL;?>/view/user/Change_pass.php" class="navi_b_4"><img src="<?php echo APPLICATION_URL;?>/images/navi/tenanto_resetpass.gif" alt="パスワード変更" width="145" height="39" /></a></li>

				        </ul>
				      </div>
				   <!-- /navi -->
				   <!-- contents -->
				       <div id="content">
				       		  <h1><img src="<?php echo APPLICATION_URL;?>/images/h1_faq.gif" alt="よくあるご質問" /></h1>
				       		  <!-- result -->
              <div id="pnlResult" class="result">             
                <p class="result">会議室<span id="lblRoomName">「会議室<?php echo $name ?>」</span>の空室状況</p>                
                <!-- price -->
                <p class="title">使用料（単位：円　税込）</p>                               
                <!-- schedule -->
                <p class="title">予約候補とする会議室の［予約］ボタンをクリックしてください。</p>
                <?php

                       //var_dump($outputTime);die;
                       if($outputTime=='none')
                       {
                       	echo "<script type='text/javascript'>\n";
						echo "alert('invalid input time');\n";
						echo "window.location=\"".APPLICATION_URL."/view/user/book_room.php\"";
						echo "</script>";
                       }
                       elseif($outputTime!=null)
                       {
                        print "<form action=\"".APPLICATION_URL."/controller/orderController.php\" method=\"post\">";       
                    	print "<table class=\"result\">";
                       print "<input type=\"hidden\" name=\"roomName\" value=\"$name\">";	
                       	//get time
                      	// Mảng ngày
                       foreach ($outputTime as $date){
                       		
                       	   //get date
                       	   $day=date('Y-m-d',strtotime($date[0]['time']));
                           //get hour    
	                       for($i=1;$i<=47;$i++){ 
		                       	if($i==1){
		                     		print "<tr>";
		                     		print "<td rowspan=\"8\" width=\"61\">$day</td>";
		                     		$hour=date('H:i',strtotime($date[$i-1]['time'])).'->'.date('H:i',strtotime($date[$i]['time']));
		                       		$orderHour=date('Y-m-d H:i:s',strtotime($date[$i-1]['time'])).'->'.date('Y-m-d H:i:s',strtotime($date[$i]['time']));
		                       		//print "<td>$hour<input type=\"checkbox\" name=\"orderTime[]\" value=\"$orderHour\"></td>";
		                       		if($date[$i-1]['flag']==1&&$date[$i]['flag']==1)
		                       			print "<td style=\"color:red\">予約された</td>";
		                       		else
		                       			print "<td>$hour<input type=\"checkbox\" name=\"orderTime[]\" value=\"$orderHour\"></td>";//$date.$i là gia tri gui len server khi an submit
		                       	}
		                       	else if($i==6||$i==12||$i==18||$i==24||$i==30||$i==36||$i==42){
		                       		$hour=date('H:i',strtotime($date[$i-1]['time'])).'->'.date('H:i',strtotime($date[$i]['time']));
		                       		$orderHour=date('Y-m-d H:i:s',strtotime($date[$i-1]['time'])).'->'.date('Y-m-d H:i:s',strtotime($date[$i]['time']));
		                       		if($date[$i-1]['flag']==1&&$date[$i]['flag']==1)
		                       		{	
		                       			print "<td style=\"color:red\">予約された</td>";
		                       			print "</tr>";	
		                       		}	
		                       		else
		                       		{	
		                       			print "<td>$hour<input type=\"checkbox\" name=\"orderTime[]\" value=\"$orderHour\"></td>";
		                       			print "</tr>";
		                       		}
		                       	}
		                       	else if($i==7||$i==13||$i==19||$i==25||$i==31||$i==37||$i==43){
		                       		$hour=date('H:i',strtotime($date[$i-1]['time'])).'->'.date('H:i',strtotime($date[$i]['time']));
		                       		$orderHour=date('Y-m-d H:i:s',strtotime($date[$i-1]['time'])).'->'.date('Y-m-d H:i:s',strtotime($date[$i]['time']));
		                       		if($date[$i-1]['flag']==1&&$date[$i]['flag']==1)
		                       		{
		                       			print "<tr>";
		                       			print "<td style=\"color:red\">予約された</td>";
		                       		}	
		                       		else
		                       		{
		                       			print "<tr>";
		                       			print "<td>$hour<input type=\"checkbox\" name=\"orderTime[]\" value=\"$orderHour\"></td>";
		                       	
		                       		}
		                       	}
		                       	else 
		                       	{
		                       		$hour=date('H:i',strtotime($date[$i-1]['time'])).'->'.date('H:i',strtotime($date[$i]['time']));
		                       		$orderHour=date('Y-m-d H:i:s',strtotime($date[$i-1]['time'])).'->'.date('Y-m-d H:i:s',strtotime($date[$i]['time']));
		                       		if($date[$i-1]['flag']==1&&$date[$i]['flag']==1)
		                       			print "<td style=\"color:red\">予約された</td>";
		                       		else
		                       		{	
		                       			print "<td>$hour<input type=\"checkbox\" name=\"orderTime[]\" value=\"$orderHour\"></td>";
		                       		}       
		                       	}            
	                       }
                       }
                       	print "</table>";
                    	print "<input type=\"Submit\" value=\"予約\">";
                		print "</form>";                       
                       }
                      ?>                   
                <!-- schedule -->
                                                
				</div>
              <!-- result -->
			  </div>
				    <!-- /contents -->			    
			</div>
	  		<!-- /main -->	  		
		      <div id="pr"><p>&nbsp;</p></div>
			</div>
	    </div>
	     <!-- /main_middle_area -->
	<div id="main_bottom_area">&nbsp;</div>
<!-- main_area -->
      
<!-- FOOTER -->
	<div id="footer_area">
	  <div id="footer">
	    <ul>
	      <li class="left"><a href="../../index.php">ホーム</a></li>
	      <li><a href="logout.php">ログアウト</a></li>
	      <li><a href="register.php">個人情報変更</a></li>
	      <li><a href="../../index.php">Q&A</a></li>
	    </ul>
	    <p>Copyright&nbsp;&copy;&nbsp;Team 08</p>
	  </div>
	</div>
<!-- FOOTER -->	
</body>
</html>